package com.ruoyi.teacher.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.teacher.domain.SysClasses;
import com.ruoyi.teacher.mapper.SysClassesMapper;
import com.ruoyi.teacher.service.ISysClassesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Validator;
import java.util.List;

/**
 * sysClassesService业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@Service
public class SysClassesServiceImpl implements ISysClassesService
{
    private static final Logger log = LoggerFactory.getLogger(SysClassesServiceImpl.class);
    @Autowired
    protected Validator validator;
    @Autowired
    private SysClassesMapper sysClassesMapper;

    /**
     * 查询sysClasses
     * 
     * @param id sysClasses主键
     * @return sysClasses
     */
    @Override
    public SysClasses selectSysClassesById(Long id)
    {
        return sysClassesMapper.selectSysClassesById(id);
    }

    /**
     * 查询sysClasses列表
     * 
     * @param sysClasses sysClasses
     * @return sysClasses
     */
    @Override
    public List<SysClasses> selectSysClassesList(SysClasses sysClasses)
    {
        return sysClassesMapper.selectSysClassesList(sysClasses);
    }

    /**
     * 新增sysClasses
     * 
     * @param sysClasses sysClasses
     * @return 结果
     */
    @Override
    public int insertSysClasses(SysClasses sysClasses)
    {
        return sysClassesMapper.insertSysClasses(sysClasses);
    }

    /**
     * 修改sysClasses
     * 
     * @param sysClasses sysClasses
     * @return 结果
     */
    @Override
    public int updateSysClasses(SysClasses sysClasses)
    {
        return sysClassesMapper.updateSysClasses(sysClasses);
    }

    /**
     * 批量删除sysClasses
     * 
     * @param ids 需要删除的sysClasses主键
     * @return 结果
     */
    @Override
    public int deleteSysClassesByIds(String ids)
    {
        return sysClassesMapper.deleteSysClassesByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除sysClasses信息
     * 
     * @param id sysClasses主键
     * @return 结果
     */
    @Override
    public int deleteSysClassesById(Long id)
    {
        return sysClassesMapper.deleteSysClassesById(id);
    }

    @Override
    public List<SysClasses> selectClassesAll() {
        return sysClassesMapper.selectClassesAll();
    }

    @Override
    public List<SysClasses> selectClassesByClassesId(Long classesId) {
        List<SysClasses> list =  selectClassesAll();
        for(SysClasses sysClasses:list){
              if(sysClasses.getId()==classesId){
                   sysClasses.setFlag(true);
                   break;
              }
        }
        return list;
    }

}
